#/usr/bin/env python
#-*- coding:utf-8 -*-
#Authot : will
import os
import sys

import django

sys.path.append('/Users/Macx/PycharmProjects/hk_news/')  # 将项目路径添加到系统搜寻路径当中
os.environ['DJANGO_SETTINGS_MODULE'] = 'hk_news.settings'  # 设置项目的配置文件

django.setup()


from test01 import models
from test01.app.test import open_url


url ='http://www.gzzk.gov.cn/zxks/kszx/'
soup = open_url(url)
data = soup.select('div.list_box2 li')

for news in data:
    title = news.a.text
    url =news.a.get('href').replace('..','http://www.gzzk.gov.cn/zxks') if '..' in news.a.get('href') else 'http://www.gzzk.gov.cn' + news.a.get('href')
    update = news.span.text
    print(title,url,update)